/*
 * @Author: liuzibin 
 * @Date: 2023-07-24 00:33:58 
 * @Descroption: 添加商品自评
 */
const axios = require("axios");

async function addVolume(params) {
  const response = await axios.post(
    "https://borderclear.cn/sys/create_reply",
    {
      // 商品id和图片
      product_id: {
        src: "https://ae01.alicdn.com/kf/Sa073ed0141cc441eb9c32bef87d89e35E/4Pcs-Vinyl-Wrap-Car-Magnet-Holder-Fixer-Carbon-Fiber-Film-Wrapping-Strong-Gripper-Magnetic-Holder-Car.jpg_250x250.jpg",
        id: 306,
      },
      nickname: generateEnglishNickname(), //用户昵称
      comment: generateProductReview(), //评论内容
      product_score: 5,
      service_score: 5,
      postage_score: 5,
      avatar:
        "https://8.217.65.128/uploads/def/20230713/b0f1fb967ee6a4e3afab13bfb78a561c.jpg",
      pics: [],
    },
    {
      headers: {
        Accept: "application/json, text/plain, */*",
        Referer: "https://borderclear.cn/admin/merchant/list",
        "User-Agent":
          "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36",
        "Content-Type": "application/json;charset=UTF-8",
      },
    }
  );

  return response.data.data.id;
}

// 生成英文昵称
function generateEnglishNickname() {
  // 名词列表
  const nouns = [
    "Star",
    "Moon",
    "Sun",
    "Rainbow",
    "Ocean",
    "Mountain",
    "Snowflake",
    "Breeze",
    "Whisper",
    "Shadow",
  ];

  // 形容词列表
  const adjectives = [
    "Sparkling",
    "Gentle",
    "Radiant",
    "Enchanting",
    "Magical",
    "Serene",
    "Mystic",
    "Luminous",
    "Spirited",
    "Dreamy",
  ];

  // 随机选择名词和形容词
  const noun = nouns[Math.floor(Math.random() * nouns.length)];
  const adjective = adjectives[Math.floor(Math.random() * adjectives.length)];

  // 返回生成的英文昵称
  return `${adjective} ${noun}`;
}

// List of positive adjectives
const positiveAdjectives = [
  "excellent",
  "great",
  "amazing",
  "impressive",
  "wonderful",
  "fantastic",
  "awesome",
  "terrific",
  "outstanding",
  "superb",
];

// List of positive nouns
const positiveNouns = [
  "product",
  "purchase",
  "item",
  "choice",
  "buy",
  "selection",
  "option",
  "investment",
  "acquisition",
  "deal",
];

// Generate a random product review
function generateProductReview() {
  // Randomly select a positive adjective and noun
  const randomAdjective =
    positiveAdjectives[Math.floor(Math.random() * positiveAdjectives.length)];
  const randomNoun =
    positiveNouns[Math.floor(Math.random() * positiveNouns.length)];

  // Construct the review content
  const review = `This ${randomAdjective} ${randomNoun} is absolutely incredible!`;

  return review;
}

module.exports = addVolume;
